info = g_ptr_array_index (priv->selectors_info, i);
- if (!_gtk_css_selector_matches (info->selector, path))
+ if (!_gtk_css_selector_matches (info->selector, path, gtk_widget_path_length (path)))
continue;
g_hash_table_iter_init (&iter, info->style);
info = g_ptr_array_index (priv->selectors_info, i);
- if (!_gtk_css_selector_matches (info->selector, path))
+ if (!_gtk_css_selector_matches (info->selector, path, gtk_widget_path_length (path)))
continue;
selector_state = _gtk_css_selector_get_state_flags (info->selector);
return FALSE;
}
+/**
+ * _gtk_css_selector_matches:
+ * @selector: the selector
+ * @path: the path to check
+ * @length: How many elements of the path are to be used
+ *
+ * Checks if the @selector matches the given @path. If @length is
+ * smaller than the number of elements in @path, it is assumed that
+ * only the first @length element of @path are valid and the rest
+ * does not exist. This is useful for doing parent matches for the
+ * 'inherit' keyword.
+ *
+ * Returns: %TRUE if the selector matches @path
+ **/
gboolean
_gtk_css_selector_matches (const GtkCssSelector *selector,
- /* const */ GtkWidgetPath *path)
+ /* const */ GtkWidgetPath *path,
+ guint length)
{
GSList *list;
- guint length;
gboolean match;
g_return_val_if_fail (selector != NULL, FALSE);
g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (length <= gtk_widget_path_length (path), FALSE);
- length = gtk_widget_path_length (path);
if (length == 0)
return FALSE;
GtkStateFlags _gtk_css_selector_get_state_flags (GtkCssSelector *selector);
gboolean _gtk_css_selector_matches (const GtkCssSelector *selector,
- /* const */ GtkWidgetPath *path);
+ /* const */ GtkWidgetPath *path,
+ guint length);
int _gtk_css_selector_compare (const GtkCssSelector *a,
const GtkCssSelector *b);